package com.rocketmq.base.example.filter;

import com.rocketmq.base.example.Const;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

/**
 * @Auther: tianchao
 * @Date: 2021/9/4 15:50
 * @Description:
 */
public class SqlFilterProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("SqlFilter_group_name");
        producer.setNamesrvAddr(Const.nameServer);
        producer.start();
        for (int i = 0; i < 8; i++) {
            Message msg = new Message("SqlFilter",
                    "Tag"+i,
                    ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
            );
// Set some properties.
            msg.putUserProperty("a", String.valueOf(i));
            SendResult sendResult = producer.send(msg);
            System.out.println(sendResult);
        }
        producer.shutdown();
    }
}
